package priv.yangguolong.Chapter06;
import java.util.Date;
import java.util.GregorianCalendar;
public class Employee02 {

	private String name;
	private double salary;
	private Date hireDay;
	
	public Employee02(String name,double salary) {
		this.name = name;
		this.salary = salary;
		hireDay = new Date();
	}
	public Employee02 clone() throws CloneNotSupportedException{
		//call Object.clone()
		Employee02 cloned = (Employee02) super.clone();
		
		//clone mutable fields
		cloned.hireDay = (Date) hireDay.clone();
		return cloned;
	}
	/**
	 * ...
	 * ...
	 */
	public void setHireDay(int year,int month,int day) {
		Date newHireDay = new GregorianCalendar(year,month - 1,day).getTime();
		//Example of instance field mutation
		hireDay.setTime(newHireDay.getTime());
	}
	public void raiseSalary(double byPercent) {
		double raise = salary * byPercent/100;
		salary += raise;
	}
	public String toString() {
		return "Employee[name="+name+",salary="+salary+"hireDay="+hireDay+"]";
	}
}
